package com.auto.learning.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.auto.learning.fragment.BaseFragment;

public class TabViewPagerAdapter extends FragmentPagerAdapter {

    private String mTabTitle[];
    private Context mContext;
    
    private ArrayList<Fragment> fragments = new ArrayList<Fragment>();

    public ArrayList<Fragment> getFragments() {
		return fragments;
	}

	public void setFragments(ArrayList<Fragment> fragments) {
		this.fragments = fragments;
	}

	public TabViewPagerAdapter(FragmentManager fm, Context context,ArrayList<Fragment> fragments , String mTabTitle[]) {
        super(fm);
        this.mContext = context;
        this.fragments = fragments;
        this.mTabTitle = mTabTitle;
    }

    @Override
    public Fragment getItem(int position) {
    	if (fragments == null) {
			return BaseFragment.newInstance(position);
		}
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return mTabTitle.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTabTitle[position];
    }
    
    
}
